/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.zjor.lwuit.ext.menu;

import com.sun.lwuit.Component;
import com.sun.lwuit.Container;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.Image;
import com.sun.lwuit.Label;
import com.sun.lwuit.List;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.list.ListCellRenderer;
import com.sun.lwuit.plaf.Border;
import java.util.Vector;
import org.zjor.lwuit.ext.images.ImageRegistry;

/**
 *
 * @author Serg
 */
public class CenteredMenuListForm extends Form{

    private CenteredListCellRenderer cellRenderer = new CenteredListCellRenderer();
    {
        Label focus = cellRenderer.getFocusLabel();
        focus.getStyle().setBgColor(0xAFAFAF);
        focus.getStyle().setBgTransparency(100);
        focus.getStyle().setBorder(Border.createRoundBorder(15, 15, 0xF0F0F0));

        Label item = cellRenderer.getItemLabel();
        item.getStyle().setBgColor(0xFEFEFE);
        item.getStyle().setBgTransparency(50);
        item.getStyle().setBorder(Border.createRoundBorder(15, 15, 0xF0F0F0));
    }


    private List menuList = new List(new SimpleModel[] {
        new SimpleModel(ImageRegistry.getImage("img3"), "image 1a"),
        new SimpleModel(ImageRegistry.getImage("img4"), "image 2ss"),
        new SimpleModel(ImageRegistry.getImage("img5"), "image 3ddd"),
        new SimpleModel(ImageRegistry.getImage("img6"), "image 4f f"),
        new SimpleModel(ImageRegistry.getImage("img7"), "image 554d"),
    });
    {
        menuList.setListCellRenderer(cellRenderer);
    }

    public CenteredMenuListForm() {
        super("Centered menu");
        setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        addComponent(menuList);
    }
}


class SimpleModel implements MenuItem{

    private Image image;
    private String name;

    public SimpleModel(Image image, String name) {
        this.image = image;
        this.name = name;
    }

    /**
     * @return the image
     */
    public Image getImage() {
        return image;
    }

    /**
     * @return the name
     */
    public String getText() {
        return name;
    }



}